function setCaptchaHtml(req)
{
    var response=req.responseXML.getElementsByTagName("captcha");
    if((response!=null)&&(response!=undefined)&&(response[0]!=null)&&(response[0]!=undefined))
    {
        var imgcaptcha=$('#imgcaptcha');
        var audcaptcha=$('#audcaptcha');
        var audUrl = '';
        var nosslAudUrl = '';
        var protocol='http';
        for(var x=0;x<response[0].attributes.length;x++)
        {
            var attribute=response[0].attributes[x];
            if(attribute.nodeName=='image')
                imgcaptcha.attr({src:attribute.nodeValue});
            else
            if(attribute.nodeName=='audio')
                audUrl=attribute.nodeValue;
            else
            if(attribute.nodeName=='nonsslaudio')
                nosslAudUrl = attribute.nodeValue;
            else
            if(attribute.nodeName=='protocol')
                protocol = attribute.nodeValue;
        }
        if((audUrl!='')&&(nosslAudUrl!=''))
        {
            var audhtml="<object width=\"100\" height=\"42\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codeBase=\""+protocol+"://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" altHtml=\"\">";
            audhtml+="<param name=\"_cx\" value=\"5080\"/>";
            audhtml+="<param name=\"_cy\" value=\"5080\"/>";
            audhtml+="<param name=\"FlashVars\" value=\"\"/>";
            audhtml+="<param name=\"Movie\" value=\"mollom-captcha-player.swf?url="+nosslAudUrl+"\"/>";
            audhtml+="<param name=\"Src\" value=\"mollom-captcha-player.swf?url="+nosslAudUrl+"\"/>";
            audhtml+="<param name=\"WMode\" value=\"Transparent\"/>";
            audhtml+="<param name=\"Play\" value=\"-1\"/>";
            audhtml+="<param name=\"Loop\" value=\"0\"/>";
            audhtml+="<param name=\"Quality\" value=\"High\"/>";
            audhtml+="<param name=\"SAlign\" value=\"\"/>";
            audhtml+="<param name=\"Menu\" value=\"0\"/>";
            audhtml+="<param name=\"Base\" value=\"\"/>";
            audhtml+="<param name=\"AllowScriptAccess\" value=\"\"/>";
            audhtml+="<param name=\"Scale\" value=\"ShowAll\"/>";
            audhtml+="<param name=\"DeviceFont\" value=\"0\"/>";
            audhtml+="<param name=\"EmbedMovie\" value=\"0\"/>";
            audhtml+="<param name=\"BGColor\" value=\"FFFFFF\"/>";
            audhtml+="<param name=\"SWRemote\" value=\"\"/>";
            audhtml+="<param name=\"MovieData\" value=\"\"/>";
            audhtml+="<param name=\"SeamlessTabbing\" value=\"1\"/>";
            audhtml+="<param name=\"Profile\" value=\"0\"/>";
            audhtml+="<param name=\"ProfileAddress\" value=\"\"/>";
            audhtml+="<param name=\"ProfilePort\" value=\"0\"/>";
            audhtml+="<param name=\"AllowNetworking\" value=\"all\"/>";
            audhtml+="<param name=\"AllowFullScreen\" value=\"false\"/>";
            audhtml+="</object>";
            audcaptcha.html(audhtml);
        }
        screen.captcha.show();
    }
}

function refreshCaptcha()
{
    var imgcaptcha=$('#imgcaptcha');
    var audcaptcha=$('#audcaptcha');
    if( $(".cpimage").is(":visible") )
    {
        var src = imgcaptcha.attr('src').split('?');
        src[1] = "?t="+(+new Date);
        imgcaptcha.attr({src: src.join('') });
    }
    if( $(".cpaudio").is(":visible") )
    {
        // can't get there from here.
    }
}

function toggleCaptcha()
{
    if( $(".cpimage").is(":visible") )
    {
        $(".cpimage").hide();
        $(".cpaudio").show();
    }
    else
    {
        $(".cpaudio").hide();
        $(".cpimage").show();
    }
}

